package com.jerei.crm.mapper;

import com.jerei.crm.entity.Contract;
import com.jerei.crm.entity.Customer;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository

public interface CustomerMapper {

    /**
     * 添加隐藏客户
     * @param customer
     * @return
     */
    Integer insert(Customer customer);


    List<Customer> selectByLike(@Param("uid") Integer uid,@Param("name") String name, @Param("tel") String tel, @Param("intention") String intention);

    /**
     * 我的转正客户模糊查询
     * @param uid
     * @param name
     * @param tel
     * @param intention
     * @return
     */
    List<Customer> selectByLikeMyCus(@Param("uid") Integer uid,@Param("name") String name, @Param("tel") String tel, @Param("intention") String intention);

    /**
     * 授权后查询客户，所有客户 uid可以为0
     * @param uid
     * @param name
     * @param tel
     * @param intention
     * @return
     */
    List<Customer> selectByLikeAll(@Param("uid") Integer uid,@Param("name") String name, @Param("tel") String tel, @Param("intention") String intention);


    List<Customer> findByLikePublic(@Param("name") String name, @Param("tel") String tel, @Param("intention") String intention);

    List<Customer> selectByUid(@Param("uid") Integer uid,@Param("num") Integer num);

    List<Customer> selectByStatus(@Param("uid") Integer uid,@Param("num") Integer num);

    List<Customer> selectPublic(Integer num);

    List<Customer> selectAll(Integer num);

    Integer countAll();

    Integer countPublic();

    Integer countCus(Integer uid);

    Integer countByStatus(Integer uid);

    Integer updateByCid(Integer cid);

    Integer addContract(Contract contract);

    List<Contract> selectContractByCid(Integer cid);

    List<Customer> selectByArrayCid(Integer[] arr);

    Integer updateByArrayCid(@Param("arr") Integer[] arr,@Param("uid") Integer uid);

    List<Customer> selectByContractCid(Integer cid);

    //获取公共客户
    Integer updatePublic(@Param("uid") Integer uid,@Param("cid") Integer cid,@Param("status") String status);
    //设置为公共客户
    Integer updAbaPublic(Integer cid);

    //删除潜在客户
    Integer deleteByCid(Integer id);

}
